## Sipeed MaiX Bit K210 Transfer Learning
-----
### Environment
```
git clone https://notabug.org/luvres/sipeed-transfer.git

cd sipeed-transfer


# [insert classes into each directory in images ]

images
├── class1
│   ├── img1.jpg
│   ├── img2.jpg
│   └── img3.jpg
└── class2
    ├── img1.jpg
    ├── img2.jpg
    └── img3.jpg

# Must change number of classes in "CLASSES =" in "mbnet_keras.py"
```
```
docker run --rm --runtime=nvidia --name OpenCV \
--publish=8888:8888 \
--mount type=bind,src=$PWD,dst=/root/noteboots \
--workdir=/root/noteboots \
-ti izone/yolo:cuda-opencv \
jupyter notebook \
        --allow-root \
        --no-browser \
        --ip=0.0.0.0 \
        --port=8888 \
        --notebook-dir=/root/noteboots \
        --NotebookApp.token=''
```
```
http://localhost:8888/
```

### And run SetUP.ipynb
```
# Install dependencies
!pip install tensorflow keras
!bash get_nncase.sh

# Train model with exit my_model.h5
!python mbnet_keras.py

# Convert to .tflite(TensorFlow Lite)
!tflite_convert --output_file=model.tflite --keras_model_file=my_model.h5

# Convert .tflite to .kmodel (K210 format)
!bash tflite2kmodel.sh model.tflite

# Create labels for classes
!ls -l images | awk '{print $NF}' | sed '1d' >labels.txt
```

-----
### References
```
# https://www.instructables.com/id/Transfer-Learning-With-Sipeed-MaiX-and-Arduino-IDE/

# https://www.fernandok.com/2019/11/chip-de-23-com-inteligencia-artificial.html
```
